package org.demo.base.config;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;

public class LogUtil {
	public static void error(Class<?> clazz, String title, String content) {
		Logger log = LoggerFactory.getLogger(clazz);
		String c = String.format("【NTS_HC_%s】 %s", title, content);
		log.error(c);
	}

	public static void error(Class<?> clazz, String title, String content, Throwable t) {
		Logger log = LoggerFactory.getLogger(clazz);
		String c = String.format("【NTS_HC_%s】 %s", title, content);
		log.error(c, t);
	}

	public static void warn(Class<?> clazz, String title, String content) {
		Logger log = LoggerFactory.getLogger(clazz);
		String c = String.format("【NTS_HC_%s】 %s", title, content);
		log.warn(c);
	}

	public static void info(Class<?> clazz, String title, String content) {
		Logger log = LoggerFactory.getLogger(clazz);
		String c = String.format("【NTS_HC_%s】 %s", title, content);
		log.info(c);
	}

	public static void info(Class<?> clazz, String title, String content, Throwable t) {
		Logger log = LoggerFactory.getLogger(clazz);
		String c = String.format("【NTS_HC_%s】 %s", title, content);
		log.info(c, t);
	}

	public static void infoAll(Class<?> clazz, Object... obj) {
		Gson gson = new Gson().newBuilder().serializeNulls().create();
		StringBuilder sb = new StringBuilder();
		for (Object object : obj) {
			sb.append(gson.toJson(object));
		}
		Logger log = LoggerFactory.getLogger(clazz);
		log.info("打印传入参数" + sb.toString());
	}
}
